package eventbus

import "time"

/*
会话事件
*/
// 会话相关事件类型
const (
	EventSessionCreated  = "session.created"
	EventSessionStarted  = "session.started"
	EventSessionPaused   = "session.paused"
	EventSessionResumed  = "session.resumed"
	EventSessionEnded    = "session.ended"
	EventSessionRemoved  = "session.removed"
	EventPlayerJoined    = "player.joined"
	EventPlayerLeft      = "player.left"
	EventSessionRestored = "session.restored"
)

// 会话事件
type SessionEvent struct {
	/*
		由于 SessionEvent和 MatchmakingEvent都嵌入了 *BaseEvent
		而 *BaseEvent实现了 Event接口，所以它们也自动实现了 Event接口
	*/
	*BaseEvent
	SessionID string `json:"session_id"`
	PlayerID  string `json:"player_id,omitempty"`
}

// 创建会话事件
func NewSessionEvent(eventType, sessionID, playerID string, data interface{}) *SessionEvent {
	return &SessionEvent{
		BaseEvent: NewBaseEvent(eventType, data),
		SessionID: sessionID,
		PlayerID:  playerID,
	}
}

// 会话数据
type SessionData struct {
	SessionID   string                 `json:"session_id"`
	State       string                 `json:"state"`
	PlayerCount int                    `json:"player_count"`
	MaxPlayers  int                    `json:"max_players"`
	CreateAt    time.Time              `json:"create_at"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}
